<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <link rel="stylesheet" type="text/css" href="__CSS__/lib/normalize.css" />
    <link rel="stylesheet" type="text/css" href="__CSS__/mui-3.6.1.min.css" />
    <link rel="stylesheet" type="text/css" href="__CSS__/tousu.css" />
    <title>投诉</title>
</head>

<body>
    <div class="mui-content">
        <div class="top-bar mui-row" onclick="history.back(-1);">
            <div class="return mui-col-sm-2 mui-col-xs-2"></div>
            <div class="top-middle mui-col-sm-8 mui-col-xs-8">
                <div class="s-top-middle">
                    投诉
                </div>
            </div>
            <div class="top-right mui-col-sm-2 mui-col-xs-2"></div>
        </div>
    </div>

    <div class="tksm">
        <textarea id="content" placeholder="亲, 说出你不满意的地方, 后续我们会有专人为你跟进投诉进度"></textarea>
    </div>
    <div class="dpmz">{$name}</div>
    <div class="dpmz"><input  id="phone" type="tel" maxlength="11" placeholder="请留下你的联系方式 (手机号)"></div>
    <div onclick="<if condition="$userId">complaint({$userId})<else/>toLogin()</if>" class="tijiao">提交</div>


<script type="text/javascript" src="__JS__/jquery2.1.1.min.js"></script>
<script type="text/javascript" src="__JS__/mui.js"></script>
<script type="text/javascript" src="__JS__/tousu.js"></script>
<script type="text/javascript">
var telReg =/^1[3|7|4|5|8]{1}\d{9}$/;

function toLogin(){
    mui.toast('请先登录');
    location.href='/Wx/Login/login';
}

function complaint(uId){

    var phone=$.trim($('#phone').val());
    var content = $.trim($('#content').val());
    if (!telReg.test(phone)) {
        mui.toast('手机格式不正确');
        return;
    }
    if(!content){
        mui.toast('还没有填写投诉内容');
    }

    var data={
        user_id : uId,
        phone   : phone,
        content : content,
        <if condition="$orderId">
            orderId : {$orderId},
        <else/>
            orderId : 0,
        </if>

        shopId  : {$shopId}
    };

    $.post('/Wx/Shop/tousu',data,function(data){
        mui.toast(data['msg']);
        if(data['pan'] == 1){
            setTimeout(function(){
                <if condition="$orderId">
                    window.location.href ="/Wx/Orders/orderDetail?id="+{$orderId}+"";
                <else/>
                    window.location.href ="/Wx/Shop/shop?id="+{$shopId}+"";
                </if>

            },2000)
        }
    },'json')
}
</script>
</body>

</html>
